package assets0

import (
	"embed"
	"io/fs"
	"strings"
)

//go:embed images/favicon.ico
var Favicon_ico []byte

//go:embed public/index.html
var IndexPublic []byte

//go:embed public/*
var FsPublic embed.FS

type AssetsPublic struct {
	embedFs embed.FS
}

func NewAssetsPublic() *AssetsPublic {
	return &AssetsPublic{
		embedFs: FsPublic,
	}
}

// 实现接口
func (me *AssetsPublic) Open(name string) (fs.File, error) {
	var path string
	if strings.HasPrefix(name, "/") {
		path = "public" + name
	} else {
		path = "public/" + name
	}
	f, err := me.embedFs.Open(path)
	return f, err
}
